home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2006 May / PCWMAY06.iso / Software / Freeware / First Page 2006 3.00 / fp2006-final-3.00-setup.exe / {app} / Iscripts / DHTML - Mouse and Cursor / circling-text.izs next >
Text File  |  2005-09-02  |  6KB  |  218 lines

  1. <!NOWIZARD>
  2.  
  3. <!TITLE>Circling text trail
  4. <!/TITLE>
  5.  
  6. <!BROWSER>IE5+<!/BROWSER>
  7.  
  8. <!DESCRIPTION> Have a textual message circle your mouse cursor and follow it around using this DHTML script.
  9. <!/DESCRIPTION> 
  10.  
  11. <!CATEGORY>mouse and cursor<!/CATEGORY>
  12.  
  13. <!SCRIPT>
  14. <!-- START OF SCRIPT -->
  15. <SCRIPT LANGUAGE="JavaScript1.2">
  16. <!--//
  17.  
  18. //Circling text trail- Tim Tilton
  19. //Website: http://www.tempermedia.com/
  20. //Visit http://www.dynamicdrive.com for this script and more
  21.  
  22. // your message here
  23. var msg='Dynamic Drive!';
  24.  
  25. var font='Verdana,Arial';
  26. var size=3; // up to seven
  27. var color='#000000';
  28.  
  29. // This is not the rotation speed, its the reaction speed, keep low!
  30. // Set this to 1 for just plain rotation w/out drag
  31. var speed=.3;
  32.  
  33. // This is the rotation speed, set it negative if you want
  34. // it to spin clockwise
  35. var rotation=.2;
  36.  
  37. // Alter no variables past here!, unless you are good
  38. //---------------------------------------------------
  39.  
  40. var ns=(document.layers);
  41. var ie=(document.all);
  42. var msg=msg.split('');
  43. var n=msg.length; 
  44. var a=size*15;
  45. var currStep=0;
  46. var ymouse=0;
  47. var xmouse=0;
  48. var scrll=0;
  49. var props="<font face="+font+" size="+size+" color="+color+">";
  50.  
  51. if (ie)
  52. window.pageYOffset=0
  53.  
  54. // writes the message
  55.     if (ns){
  56.     for (i=0; i < n; i++)
  57.         document.write('<layer name="nsmsg'+i+'" top=0 left=0 height='+a+' width='+a+'><center>'+props+msg[i]+'</font></center></layer>');
  58.     }
  59.     if (ie){
  60.         document.write('<div id="outer" style="position:absolute;top:0px;left:0px"><div style="position:relative">');
  61.         for (i=0; i < n; i++)
  62.             document.write('<div id="iemsg" style="position:absolute;top:0px;left:0;height:'+a+';width:'+a+';text-align:center;font-weight:regular;cursor:default">'+props+msg[i]+'</font></div>');
  63.             document.write('</div></div>');
  64.     }
  65.     (ns)?window.captureEvents(Event.MOUSEMOVE):0;
  66.  
  67. function Mouse(evnt){
  68.     ymouse = (ns)?evnt.pageY+20-(window.pageYOffset):event.y; // y-position
  69.     xmouse = (ns)?evnt.pageX+20:event.x-20; // x-position
  70. }
  71.  
  72. if (ns||ie)
  73. (ns)?window.onMouseMove=Mouse:document.onmousemove=Mouse;
  74. y=new Array();
  75. x=new Array();
  76. Y=new Array();
  77. X=new Array();
  78. for (i=0; i < n; i++){
  79.     y[i]=0;
  80.     x[i]=0;
  81.     Y[i]=0;
  82.     X[i]=0;
  83. }
  84.  
  85. function makecircle(){ // rotation properties
  86. if (ie) outer.style.top=document.body.scrollTop;
  87. currStep-=rotation;
  88.     for (i=0; i < n; i++){ // makes the circle
  89.         var d=(ns)?document.layers['nsmsg'+i]:iemsg[i].style;
  90.         d.top=y[i]+a*Math.sin((currStep+i*1)/3.8)+window.pageYOffset-15;
  91.         d.left=x[i]+a*Math.cos((currStep+i*1)/3.8)*2; // remove *2 for just a plain circle, not oval
  92.     }
  93. }
  94.  
  95. function drag(){ // makes the resistance
  96.     scrll=(ns)?window.pageYOffset:0;
  97.     y[0]=Math.round(Y[0]+=((ymouse)-Y[0])*speed);
  98.     x[0]=Math.round(X[0]+=((xmouse)-X[0])*speed);
  99.     for (var i=1; i < n; i++){
  100.         y[i]=Math.round(Y[i]+=(y[i-1]-Y[i])*speed);
  101.         x[i]=Math.round(X[i]+=(x[i-1]-X[i])*speed);
  102.  
  103.     }
  104.     makecircle();
  105.     // not rotation speed, leave at zero
  106.     setTimeout('drag()',10);
  107. }
  108. if (ns||ie)window.onload=drag;
  109.  
  110. // -->
  111. </SCRIPT>
  112. <!-- END OF SCRIPT -->
  113. <!/SCRIPT>
  114.  
  115. <!PREVIEW>
  116. <!-- START OF SCRIPT -->
  117. <SCRIPT LANGUAGE="JavaScript1.2">
  118. <!--//
  119.  
  120. //Circling text trail- Tim Tilton
  121. //Website: http://www.tempermedia.com/
  122. //Visit http://www.dynamicdrive.com for this script and more
  123.  
  124. // your message here
  125. var msg='Dynamic Drive!';
  126.  
  127. var font='Verdana,Arial';
  128. var size=3; // up to seven
  129. var color='#000000';
  130.  
  131. // This is not the rotation speed, its the reaction speed, keep low!
  132. // Set this to 1 for just plain rotation w/out drag
  133. var speed=.3;
  134.  
  135. // This is the rotation speed, set it negative if you want
  136. // it to spin clockwise
  137. var rotation=.2;
  138.  
  139. // Alter no variables past here!, unless you are good
  140. //---------------------------------------------------
  141.  
  142. var ns=(document.layers);
  143. var ie=(document.all);
  144. var msg=msg.split('');
  145. var n=msg.length; 
  146. var a=size*15;
  147. var currStep=0;
  148. var ymouse=0;
  149. var xmouse=0;
  150. var scrll=0;
  151. var props="<font face="+font+" size="+size+" color="+color+">";
  152.  
  153. if (ie)
  154. window.pageYOffset=0
  155.  
  156. // writes the message
  157.     if (ns){
  158.     for (i=0; i < n; i++)
  159.         document.write('<layer name="nsmsg'+i+'" top=0 left=0 height='+a+' width='+a+'><center>'+props+msg[i]+'</font></center></layer>');
  160.     }
  161.     if (ie){
  162.         document.write('<div id="outer" style="position:absolute;top:0px;left:0px"><div style="position:relative">');
  163.         for (i=0; i < n; i++)
  164.             document.write('<div id="iemsg" style="position:absolute;top:0px;left:0;height:'+a+';width:'+a+';text-align:center;font-weight:regular;cursor:default">'+props+msg[i]+'</font></div>');
  165.             document.write('</div></div>');
  166.     }
  167.     (ns)?window.captureEvents(Event.MOUSEMOVE):0;
  168.  
  169. function Mouse(evnt){
  170.     ymouse = (ns)?evnt.pageY+20-(window.pageYOffset):event.y; // y-position
  171.     xmouse = (ns)?evnt.pageX+20:event.x-20; // x-position
  172. }
  173.  
  174. if (ns||ie)
  175. (ns)?window.onMouseMove=Mouse:document.onmousemove=Mouse;
  176. y=new Array();
  177. x=new Array();
  178. Y=new Array();
  179. X=new Array();
  180. for (i=0; i < n; i++){
  181.     y[i]=0;
  182.     x[i]=0;
  183.     Y[i]=0;
  184.     X[i]=0;
  185. }
  186.  
  187. function makecircle(){ // rotation properties
  188. if (ie) outer.style.top=document.body.scrollTop;
  189. currStep-=rotation;
  190.     for (i=0; i < n; i++){ // makes the circle
  191.         var d=(ns)?document.layers['nsmsg'+i]:iemsg[i].style;
  192.         d.top=y[i]+a*Math.sin((currStep+i*1)/3.8)+window.pageYOffset-15;
  193.         d.left=x[i]+a*Math.cos((currStep+i*1)/3.8)*2; // remove *2 for just a plain circle, not oval
  194.     }
  195. }
  196.  
  197. function drag(){ // makes the resistance
  198.     scrll=(ns)?window.pageYOffset:0;
  199.     y[0]=Math.round(Y[0]+=((ymouse)-Y[0])*speed);
  200.     x[0]=Math.round(X[0]+=((xmouse)-X[0])*speed);
  201.     for (var i=1; i < n; i++){
  202.         y[i]=Math.round(Y[i]+=(y[i-1]-Y[i])*speed);
  203.         x[i]=Math.round(X[i]+=(x[i-1]-X[i])*speed);
  204.  
  205.     }
  206.     makecircle();
  207.     // not rotation speed, leave at zero
  208.     setTimeout('drag()',10);
  209. }
  210. if (ns||ie)window.onload=drag;
  211.  
  212. // -->
  213. </SCRIPT>
  214.  
  215. <!-- END OF SCRIPT -->
  216. <!/PREVIEW>
  217.  
  218. <!RELATED>NONE<!/RELATED>